﻿using FluentNHibernate.Mapping;
using Journal.Domain.Models;

namespace Journal.NHibernate.Mappings
{
    public class EducationInstitutionMap : ClassMap<EducationInstitution>
    {
        public EducationInstitutionMap()
        {
            Id(x => x.Id).GeneratedBy.Identity().Not.Nullable();
            Map(x => x.City).Length(50).Not.Nullable();
            Map(x => x.Email).Length(50).Not.Nullable();
            Map(x => x.Phone).Length(50).Not.Nullable();
            Map(x => x.Name).Length(50).Not.Nullable();
            Map(x => x.Region).Length(50).Not.Nullable();
            Map(x => x.WebSite).Length(50).Not.Nullable();
            Map(x => x.ShortName).Length(50);
            HasMany(x => x.StudyGroups).KeyColumn("EducationInstitutionId").Cascade.None().Inverse();
            References(x => x.Director).Cascade.None().LazyLoad().Not.Nullable();
        }
    }
}